package com.dictionary.pojo;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.AllArgsConstructor;
import lombok.Builder;

import java.util.ArrayList;
import java.util.List;

@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class Word {
    private Long id;
    
    @JsonProperty("word")
    private String word;
    
    @JsonProperty("ukPhonetic")
    private String ukPhonetic;
    
    @JsonProperty("usPhonetic")
    private String usPhonetic;
    
    @JsonProperty("ukAudioUrl")
    private String ukAudioUrl;
    
    @JsonProperty("usAudioUrl")
    private String usAudioUrl;
    
    @JsonProperty("details")
    private List<WordDetail> details = new ArrayList<>();
    
    @JsonProperty("bookId")
    private String bookId;
    
    @JsonProperty("info")
    private String info;

    public void addDetail(WordDetail detail) {
        this.details.add(detail);
    }

    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    @Builder
    public static class WordDetail {
        @JsonProperty("type")
        private String type; // TRANSLATION, PHRASE, EXAMPLE_SENTENCE
        
        @JsonProperty("pos")
        private String pos; // 词性
        
        @JsonProperty("chinese")
        private String chinese;
        
        @JsonProperty("english")
        private String english;
    }
}